//
// Created by hamlet on 2022/1/14.
//

#ifndef SNAKE_GAME_MESSAGE_H
#define SNAKE_GAME_MESSAGE_H

#include <QJsonObject>

class Message {
public:
    enum class Type {
        PlayerInfo, RoomInfo, DeleteRoomMessage,
        AllPlayerInfo, NewPlayerMessage, DeletePlayerMessage, TextMessage,
        StartGameMessage, SnakeDirectionChangeMessage, NewFruitMessage,
        Unknown
    };

    explicit Message(Type type);
    virtual ~Message() = default;
    [[nodiscard]] Type getType() const { return m_messageType; }

    static Message *parseJson(const QJsonObject &json);
    [[nodiscard]] virtual QJsonObject toJson() const = 0;

private:
    Type m_messageType = Type::Unknown;
};

#endif //SNAKE_GAME_MESSAGE_H
